package SynchronizedStudy;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2022-11-27
 * Time: 20:24
 */
class Number5{
    public synchronized static void a(){
        System.out.println("1");
    }
    public synchronized void b(){
        System.out.println("2");
    }
}
public class TestBlock5 {
    public static void main(String[] args) throws InterruptedException {
        Number5 n = new Number5();
        Thread t1 = new Thread(()->{
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("t1->begin!!!");
            n.a();
        });
        Thread t2 = new Thread(()->{
            System.out.println("t2->begin!!!");
            n.b();
        });
        t1.start();
        t2.start();
        t1.join();
        t2.join();
    }
}
